package tech.xs.sys.domain.bo.dict;

import cn.hutool.core.util.StrUtil;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import tech.xs.common.framework.domain.bo.PageBo;
import tech.xs.sys.domain.entity.SysDict;
import tech.xs.sys.domain.entity.SysDictData;

@Getter
@Setter
@ToString
public class QueryDictDataBo extends PageBo<SysDictData> {

    private String dictCode;

    private String likeName;

    private String likeCode;

    public MPJLambdaWrapper<SysDictData> query() {
        return new MPJLambdaWrapper<SysDictData>()
                .selectAll(SysDictData.class)
                .leftJoin(SysDict.class, SysDict::getId, SysDictData::getDictId)
                .eq(StrUtil.isNotBlank(dictCode), SysDict::getCode, dictCode)
                .like(StrUtil.isNotBlank(likeName), SysDictData::getName, likeName)
                .like(StrUtil.isNotBlank(likeCode), SysDictData::getCode, likeCode)
                .orderByAsc(SysDictData::getOrderValue, SysDictData::getCreatedTime);
    }

}
